//
//  ThumbCell.m
//  NaRiLSVMT
//
//  Created by zhangmeng on 14-9-18.
//  Copyright (c) 2014年 helloyouth.org. All rights reserved.
//

#import "HeadItem.h"
#import "TimerDownImage.h"
#define MJRandomColor [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1]
@implementation HeadItem

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    self.dataDic  = [NSMutableDictionary dictionary];
    self.backgroundColor = ColorRGB(25,76,86);
    self.layer.borderWidth = 1.5;
    self.layer.borderColor = ColorRGB(18,48,58).CGColor;
    setViewCorner(self,8);
}

- (void)reloadHeadItem:(NSString *)imageUrl Name:(NSString *)name Number:(NSString *)number{
    if(![Common isEmptyString:imageUrl]){
        if([self.dataDic[@"width"] intValue] && [self.dataDic[@"height"] intValue]){
            [self.headImgV setImage:[[DownloadImage sharedInstance] getUrlImage:[NSString stringWithFormat:@"%@_thumb",imageUrl] Block:^(UIImage *image){
                [self.headImgV setImage:image];
            }]];
        }
        else{
            self.headImgV = nil;
            //启动刷新定时器
            if(![[TimerDownImage sharedInstance] startflag]) {
                [[TimerDownImage sharedInstance] stratTimerflushThumb];
            }
        }
    }
    else{
        [self.headImgV setImage:[Common drawImageSize:CGSizeMake(220,60) Color:MJRandomColor]];
        Alert(@"templated为空");
    }
    
    self.nameLab.text = name;
    
    self.numberlab.text = number;
    
}
- (IBAction)clickHeadImgVAction:(id)sender{
    if (isDelegate(self.delegate, didSelectHeadItem:)) {
        [self.delegate didSelectHeadItem:self];
    }
}
/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect
 {
 // Drawing code
 }
 */

@end
